package GUI.Log;

import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import IO.Log;

public class LogView implements Runnable
{
	private JFrame frame;
	private JPanel panel;
	private JList list;
	private JScrollPane scrollPane;
	public LogView()
	{
		frame = new JFrame("Log Viewer");
		panel = new JPanel();
		list = new JList(Log.logs);
		
		scrollPane = new JScrollPane(list);
		panel.add(scrollPane);
		frame.add(panel);
		frame.pack();
		frame.setVisible(true);
		Thread thread = new Thread(this);
		thread.start();
	}

	@Override
	public void run() 
	{
		while(true){
			if(this.frame.isActive())
			{
				this.list.revalidate();
				this.list.repaint();
				
				this.scrollPane.revalidate();
				this.scrollPane.repaint();
				
				this.panel.revalidate();
				this.panel.repaint();
				
				this.frame.repaint();
			}
		}
	}
}